<?php if ($admin) { ?>
    <form class="form-horizontal" action="<?= current_url() ?>" method="post" id="form-validate" >
        <div id="validation" class="row-fluid">
            <div class="span12">
                <div class="box corner-all">
                    <div class="box-header grd-white color-silver-dark corner-top">
                        <div class="header-control">
                            <a data-box="collapse"><i class="icofont-caret-up"></i></a>

                        </div>
                        <span><?= lang('label_menu_link_my_data'); ?></span>
                    </div>
                    <div class="box-body">

                        <fieldset>
                            <legend><?= (isset($admin)) ? lang('label_edit') . ' ' . $admin->username : lang('label_add') . " " . lang('label_by_mode_user'); ?></legend>

                            <div class="control-group">
                                <label class="control-label" for="fname"><?= lang('label_fname') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="fname" placeholder="<?= lang('label_fname') ?>" id="fname"  value="<?= (isset($admin->first_name)) ? $admin->first_name : form_val('fname') ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="mname"><?= lang('label_mname') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="mname" placeholder="<?= lang('label_mname') ?>" id="mname"  value="<?= (isset($admin->middle_name)) ? $admin->middle_name : form_val('mname') ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="lname"><?= lang('label_lname') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="lname" placeholder="<?= lang('label_lname') ?>" id="lname"  value="<?= (isset($admin->last_name)) ? $admin->last_name : form_val('lname') ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label"><?= lang('label_gender') ?></label>
                                <div class="controls">
                                    <label for="male" style="width: auto; float: none"><input style="width: 2px" name="gender" id="male" value="male" type="radio" <?php
                                        if (form_val('gender') == 'male') {
                                            echo 'checked';
                                        } else {
                                            if ($admin->gender == 'MA')
                                                echo 'checked';
                                        }
                                        ?> > <?php echo lang('label_male') ?></label>
                                    <label for="female" style="width: auto; float: none"><input style="width: 2px" name="gender" id="female" value="female" type="radio" <?php
                                        if (form_val('gender') == 'female') {
                                            echo 'checked';
                                        } else {
                                            if ($admin->gender == 'FE')
                                                echo 'checked';
                                        }
                                        ?> ><?php echo lang('label_female') ?></label>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label"><?= lang('label_birthday') ?></label>
                                <div class="controls">
                                    <select name="day" id="day">
                                        <?php for ($i = 1; $i <= 31; $i++) { ?>
                                            <option value="<?= $i ?>" <?php
                                            if (form_val('day') == $i) {
                                                echo 'selected';
                                            } else {
                                                if ($admin->day == $i)
                                                    echo 'selected';
                                            }
                                            ?>><?= $i ?></option>
                                                <?php } ?>
                                    </select>

                                    <select name="month" id="month">
                                        <?php for ($i = 1; $i <= 12; $i++) { ?>
                                            <option value="<?= $i ?>" <?php
                                            if (form_val('month') == $i) {
                                                echo 'selected';
                                            } else {
                                                if ($admin->month == $i)
                                                    echo 'selected';
                                            }
                                            ?>><?= lang('label_m' . $i) ?></option>
                                                <?php } ?>
                                    </select>

                                    <select name="year" id="year">
                                        <?php
                                        for ($i = 0; $i < 80; $i++) {
                                            $date = date('Y') - ($i + 16);
                                            ?>
                                            <option value="<?= $date ?>" <?php
                                            if (form_val('year') == $date) {
                                                echo 'selected';
                                            } else {
                                                if ($admin->year == $date)
                                                    echo 'selected';
                                            }
                                            ?>><?= $date ?></option>
                                                <?php } ?>
                                    </select>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="city"><?= lang('label_city') ?></label>
                                <div class="controls">
                                    <select name="city" id="city">
                                        <?php foreach ($cities as $ct) { ?>
                                            <option value="<?= $ct->id ?>" <?php
                                            if (form_val('city') == $ct->id) {
                                                echo 'selected';
                                            } else {
                                                if ($admin->city_id == $ct->id)
                                                    echo 'selected';
                                            }
                                            ?>><?= $ct->title ?></option>
                                                <?php } ?>
                                    </select>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="mobile"><?= lang('label_mobile') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="mobile" placeholder="<?= lang('label_mobile') ?>" id="mobile"  value="<?= (isset($admin->mobile)) ? $admin->mobile : form_val('mobile') ?>" />
                                </div>
                            </div>
                            
                            <div class="control-group">
                                <label class="control-label" for="username"><?= lang('label_username') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="username" placeholder="<?= lang('label_username') ?>" id="username"  value="<?= (isset($admin->username)) ? $admin->username : form_val('username') ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="email"><?= lang('label_email') ?></label>
                                <div class="controls">
                                    <input type="email" class="grd-white" value="<?= (isset($admin->email)) ? $admin->email : form_val('email') ?>" name="email" placeholder="<?= lang('label_email') ?>" id="email" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="oldpassword"><?= lang('label_old_password') ?></label>
                                <div class="controls">
                                    <input type="password" class="grd-white" placeholder="<?= lang('label_old_password') ?>" value="<?= form_val('oldpassword') ?>" name="oldpassword" id="oldpassword" />
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="password"><?= lang('label_new_password') ?></label>
                                <div class="controls">
                                    <input type="password" class="grd-white" placeholder="<?= lang('label_new_password') ?>" value="<?= form_val('password') ?>" name="password" id="password" />
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="confpassword"><?= lang('label_confpassword') ?></label>
                                <div class="controls">
                                    <input type="password" class="grd-white" placeholder="<?= lang('label_confpassword') ?>" value="<?= form_val('confpassword') ?>" name="confpassword" id="confpassword" />
                                </div>
                            </div>
                            <input type="hidden" name="mode" value="<?= $admin->mode ?>">

                            <div class="form-actions">
                                <button type="submit" class="btn btn-primary"><li class="icon-edit"></li><?= (isset($admin)) ? lang('label_edit') : lang('label_add'); ?></button>
                                <button type="button" class="btn">Cancel</button>
                            </div>
                        </fieldset>


                    </div>
                </div>
            </div>
        </div>

        <div id="roles"></div>
    </form>
    <?php
} else {
    redirect(ADMIN_FOLDER . '/dashboard');
}
?>